package cn.bgs.service.impl;

import cn.bgs.DealershipManagement.pojo.VehicleArea;
import cn.bgs.mapper.CwlMapper;
import cn.bgs.service.Cwlservice;
import cn.bgs.utils.MybatisPageHelper;
import cn.bgs.utils.PageResult;
import cn.bgs.utils.R;
import cn.bgs.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CwlServiceImpl implements Cwlservice {

    @Autowired
    CwlMapper cwlMapper;

    @Override
    public R selectAllinfo(AreaVo areaVo) {
        MybatisPageHelper.startPage(areaVo.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(cwlMapper.selectAllinfo(areaVo));
        return R.ok().data("data", pageResult);
    }

    //    修改区域信息
    @Override
    public boolean updateInfo(VehicleArea vehicleArea) {
        int i = cwlMapper.updateInfo(vehicleArea);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean addInfo(VehicleArea vehicleArea) {
        boolean a = cwlMapper.addInfo(vehicleArea);
        return a;
    }

    @Override
    public R delteInfo(Integer vehicleAreaId) {
        int delet = cwlMapper.delteInfo(vehicleAreaId);
        return R.ok().data("delet", delet);
    }

    @Override
    public R selectcarInfo(MonthVo monthVo) {
        MybatisPageHelper.startPage(monthVo.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(cwlMapper.selectcarInfo(monthVo));
        return R.ok().data("data", pageResult);
    }

    @Override
    public R info(CommunityVo communityVo) {
        List<AreaVo> list = cwlMapper.info(communityVo);
        return R.ok().data("data", list);
    }

    @Override
    public boolean updateYKinfo(MonthVo monthVo) {
        int i = cwlMapper.updateYKinfo(monthVo);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean addYkInfo(MonthVo monthVo) {
        boolean a = cwlMapper.addYkInfo(monthVo);
        return a;
    }

    @Override
    public R delYkInfo(Integer vehicleMonthcarId) {
        int delte = cwlMapper.delYkInfo(vehicleMonthcarId);
        return R.ok().data("data", delte);
    }

    @Override
    public R selectnumInfo(CwnumVo cwnumVo) {
        System.out.println("page:" + cwnumVo.getPageRequest());
        MybatisPageHelper.startPage(cwnumVo.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(cwlMapper.selectnumInfo(cwnumVo));
        return R.ok().data("data", pageResult);
    }

    @Override
    public R selectAllUser(UserVo userVo) {
        List<UserVo> list = cwlMapper.selectAllUser(userVo);
        return R.ok().data("data", list);
    }

    @Override
    public boolean insertCWinfo(CwnumVo cwnumVo) {
        boolean a = cwlMapper.insertCWinfo(cwnumVo);
        return a;
    }

    @Override
    public R delCWInfo(Integer vehicleNumberId) {
        int del = cwlMapper.delCWInfo(vehicleNumberId);
        return R.ok().data("data", del);
    }

    @Override
    public boolean updateCwInfo(CwnumVo cwnumVo) {
        int i = cwlMapper.updateCwInfo(cwnumVo);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public R CWinfo(CwnumVo cwnumVo) {
        List<CwnumVo> list = cwlMapper.CWinfo(cwnumVo);
        return R.ok().data("data", list);
    }

    @Override
    public R getCarinfo(CarInfoVo carInfoVo) {
        List<CarInfoVo> list = cwlMapper.getCarinfo();
        return R.ok().data("data", list);
    }

    @Override
    public R selectParkInfo(TemporVo temporVo) {
        MybatisPageHelper.startPage(temporVo.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(cwlMapper.selectParkInfo(temporVo));
        return R.ok().data("data", pageResult);
    }

    @Override
    public boolean updateParkInfo(TemporVo temporVo) {
        int i = cwlMapper.updateParkInfo(temporVo);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean aedParkInfo(TemporVo temporVo) {
        boolean a = cwlMapper.aedParkInfo(temporVo);
        return a;
    }

    @Override
    public R deleteParkInfo(Integer temporaryCarParkId) {
        int deleteP = cwlMapper.deleteParkInfo(temporaryCarParkId);
        return R.ok().data("deleteP", deleteP);
    }

    @Override
    public R selectCarInfo(VehicleCar vehicleCar) {
        MybatisPageHelper.startPage(vehicleCar.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(cwlMapper.selectCarInfo(vehicleCar));
        return R.ok().data("data", pageResult);
    }

    @Override
    public R deleteInfo(Integer vehicleCarId) {
        int delete = cwlMapper.deleteInfo(vehicleCarId);
        return R.ok().data("delete", delete);
    }

    @Override
    public boolean addVcarInfo(VehicleCar vehicleCar) {
        boolean a = cwlMapper.addVcarInfo(vehicleCar);
        return a;
    }

    @Override
    public boolean updateInfocar(VehicleCar vehicleCar) {
        int i = cwlMapper.updateInfocar(vehicleCar);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public R infoPc(UserVo userVo) {
        List<VehicleCar> list = cwlMapper.infoPc(userVo);
        return R.ok().data("data", list);
    }

    @Override
    public R getAllFk(VisitorsRecordVo visitorsRecordVo) {
        List<VisitorsRecordVo> list = cwlMapper.getAllFk(visitorsRecordVo);
        return R.ok().data("data", list);
    }

    @Override
    public R selectAllCar(CarInfoVo carInfoVo) {
        List<CarInfoVo> list = cwlMapper.selectAllCar(carInfoVo);
        return R.ok().data("data", list);
    }

    @Override
    public boolean updateInfoC(CwnumVo cwnumVo) {
        int i = cwlMapper.updateInfoC(cwnumVo);
        if (i > 0){
            return true;
        }
        return false;

    }
}
